﻿using System.Collections.Generic;
using Aquarinum.Base.Infrastructure.WebSocket.Extensions;
using Aquarinum.Base.Service.Http;
using Aquarinum.WebSocekt.Core.Dtos;
using Microsoft.AspNetCore.Mvc;

namespace Aquarinum.WebSocket.Server.Controllers
{
    /// <summary>
    ///     授权
    /// </summary>
    [Route("Api/Auth")]
    public class AuthController : AquarinumApiController
    {
        /// <summary>
        ///     创建连接token
        /// </summary>
        /// <returns></returns>
        [HttpPost("CreateToken")]
        public  AuthResultDto CreateToken([FromBody] HandShakeDto handShakeDto)
        {
            return new AuthResultDto
            {
                Token = JwtTokenHelper.EncodeJwtToken(new Dictionary<string, dynamic> {{"handShake", handShakeDto}})
            };
        }
    }
}